package com.hb.config.web;

import com.hb.commons.MsgEnum;
import com.hb.commons.ResponseDto;
import com.hb.util.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 统一异常处理类<br>
 * 捕获程序所有异常，针对不同异常，采取不同的处理方式
 *
 * @author zhaojk
 */
@Slf4j
@RestControllerAdvice
public class ExceptionHandleController {

    /**
     * 其他异常返回
     *
     * @param ex
     *
     * @return
     */
    @ExceptionHandler(Exception.class)
    public ResponseDto handleShiroException(Exception ex) {
        ResponseDto resp = ResultUtil.msg(MsgEnum.PROCESSES_IS_DUE);
        resp.setData(ex.getMessage());
        return resp;
    }

}